﻿using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

using Shove.Alipay;

public partial class OnlinePay_Alipay02_Send : PageBase
{
    public string OnlinePay_99Bill_HomePage = "", OnlinePay_99Bill_Status = "", OnlinePay_99Bill_Target = "_self";
    public string OnlinePay_CBPayMent_HomePage = "", OnlinePay_CBPayMent_Status = "", OnlinePay_CBPayMent_Target = "_self";
    public string OnlinePay_Tenpay_HomePage = "", OnlinePay_Tenpay_Status = "", OnlinePay_Tenpay_Target = "_self";
    public string OnlinePay_Alipay_HomePage = "", OnlinePay_Alipay_Status = "", OnlinePay_Alipay_Target = "_self";
    public string OnlinePay_CnCard_HomePage = "", OnlinePay_CnCard_Status = "", OnlinePay_CnCard_Target = "_self";
    public string OnlinePay_ICBC_HomePage = "", OnlinePay_ICBC_Status = "", OnlinePay_ICBC_Target = "_self";
    public string OnlinePay_CMBChina_HomePage = "", OnlinePay_CMBChina_Status = "", OnlinePay_CMBChina_Target = "_self";

    public double Money = 0;
    public double RealPayMoney = 0;

    public int RelatedOrderType = 0;
    public long RelatedOrderID = 0;

    protected void Page_Load(object sender, EventArgs e)
    {
        SystemOptions s = new SystemOptions();//读取系统设置tbl_Options里的总站支付配置信息,若要设置店铺的支付设置,请查询tbl_Shop表

        if (!IsPostBack)
        {
            bool OnlinePay_Alipay_Status_ON = s["OnlinePay_Alipay_Status_ON"].ToBoolean(false);
            if (!OnlinePay_Alipay_Status_ON)
            {
                //未启用此项服务

                return;
            }

            this.PayMoney.Enabled = false;
            Money = Shove._Convert.StrToDouble(Shove._Web.Utility.GetRequest("PayMoney"), 0);
            RealPayMoney = Money;

            // RelatedOrderType：1 商城订单
            int RelatedOrderType = Shove._Convert.StrToInt(Shove._Web.Utility.GetRequest("RelatedOrderType"), -1);
            long RelatedOrderID = Shove._Convert.StrToLong(Shove._Web.Utility.GetRequest("RelatedOrderID"), -1);

            if (Money <= 0)
            {
                Shove._Web.JavaScript.Alert(this.Page, "请输入正确金额", "Default.aspx");

                return;
            }

            double FormalitiesFeesScale = s["OnlinePay_Alipay_PayFormalitiesFeesScale"].ToDouble(0) / 100;
            double FormalitiesFees = Math.Round(Money * FormalitiesFeesScale, 2);

            Money += FormalitiesFees;
            this.PayMoney.Enabled = true;
            this.PayMoney.Text = Money.ToString();
            this.tbFormalitiesFees.Text = FormalitiesFees.ToString();
            labFormalitiesFees.Text = "手续费 " + FormalitiesFees.ToString() + " 元由支付网关提供商收取。";
            this.PayMoney.Enabled = false;

            string Description = "金额：" + (Money - FormalitiesFees).ToString() + " " + (labFormalitiesFees.Text != "" ? labFormalitiesFees.Text : "");
            lab1.Text = Description;
            lab2.Text = Description;
            lab3.Text = Description;
            lab4.Text = Description;
            lab5.Text = Description;
            lab6.Text = Description;
            lab7.Text = Description;
            lab8.Text = Description;
            lab9.Text = Description;
            lab10.Text = Description;
            lab11.Text = Description;
            lab12.Text = Description;
            lab13.Text = Description;
            lab14.Text = Description;
            lab15.Text = Description;
            lab16.Text = Description;

            hl1.NavigateUrl = "Send2.aspx?PayMoney=" + RealPayMoney.ToString() + "&BankCode=Alipay&RelatedOrderType=" + RelatedOrderType.ToString() + "&RelatedOrderID=" + RelatedOrderID.ToString();
            hl1_1.NavigateUrl = "Send2.aspx?PayMoney=" + RealPayMoney.ToString() + "&BankCode=Alipay&RelatedOrderType=" + RelatedOrderType.ToString() + "&RelatedOrderID=" + RelatedOrderID.ToString();

            hl5.NavigateUrl = "Send2.aspx?PayMoney=" + RealPayMoney.ToString() + "&BankCode=ICBCB2C&RelatedOrderType=" + RelatedOrderType.ToString() + "&RelatedOrderID=" + RelatedOrderID.ToString();
            hl6.NavigateUrl = "Send2.aspx?PayMoney=" + RealPayMoney.ToString() + "&BankCode=CMB&RelatedOrderType=" + RelatedOrderType.ToString() + "&RelatedOrderID=" + RelatedOrderID.ToString();
            hl7.NavigateUrl = "Send2.aspx?PayMoney=" + RealPayMoney.ToString() + "&BankCode=CCB&RelatedOrderType=" + RelatedOrderType.ToString() + "&RelatedOrderID=" + RelatedOrderID.ToString();
            hl8.NavigateUrl = "Send2.aspx?PayMoney=" + RealPayMoney.ToString() + "&BankCode=ABC&RelatedOrderType=" + RelatedOrderType.ToString() + "&RelatedOrderID=" + RelatedOrderID.ToString(); ;
            hl9.NavigateUrl = "Send2.aspx?PayMoney=" + RealPayMoney.ToString() + "&BankCode=SPDB&RelatedOrderType=" + RelatedOrderType.ToString() + "&RelatedOrderID=" + RelatedOrderID.ToString();
            hl10.NavigateUrl = "Send2.aspx?PayMoney=" + RealPayMoney.ToString() + "&BankCode=CIB&RelatedOrderType=" + RelatedOrderType.ToString() + "&RelatedOrderID=" + RelatedOrderID.ToString();
            hl11.NavigateUrl = "Send2.aspx?PayMoney=" + RealPayMoney.ToString() + "&BankCode=GDB&RelatedOrderType=" + RelatedOrderType.ToString() + "&RelatedOrderID=" + RelatedOrderID.ToString();
            hl12.NavigateUrl = "Send2.aspx?PayMoney=" + RealPayMoney.ToString() + "&BankCode=SDB&RelatedOrderType=" + RelatedOrderType.ToString() + "&RelatedOrderID=" + RelatedOrderID.ToString();
            hl13.NavigateUrl = "Send2.aspx?PayMoney=" + RealPayMoney.ToString() + "&BankCode=CMBC&RelatedOrderType=" + RelatedOrderType.ToString() + "&RelatedOrderID=" + RelatedOrderID.ToString();
            hl14.NavigateUrl = "Send2.aspx?PayMoney=" + RealPayMoney.ToString() + "&BankCode=COMM&RelatedOrderType=" + RelatedOrderType.ToString() + "&RelatedOrderID=" + RelatedOrderID.ToString();
            hl15.NavigateUrl = "Send2.aspx?PayMoney=" + RealPayMoney.ToString() + "&BankCode=POSTGC&RelatedOrderType=" + RelatedOrderType.ToString() + "&RelatedOrderID=" + RelatedOrderID.ToString();
            hl16.NavigateUrl = "Send2.aspx?PayMoney=" + RealPayMoney.ToString() + "&BankCode=CITIC&RelatedOrderType=" + RelatedOrderType.ToString() + "&RelatedOrderID=" + RelatedOrderID.ToString();
        }
    }

    #region Web 窗体设计器生成的代码

    protected override void OnLoad(EventArgs e)
    {
        isRequestLogin = true;

        base.OnLoad(e);
    }

    #endregion
}